package com.sophialex.health.record.common.validate;

import java.util.List;

/**
 * 验证基类
 * <p>Title:Health</p>
 * <p>BaseVerify</p>
 * 
 * Alex May 9, 2011 9:26:33 PM create
 * @author <a href='wanghao924@126.com'>Alex</a>
 * QQ: 873987060;
 * @version 1.0
 */
public class BaseVerify<T> {
	/**
	 * 是否继续验证后续动作
	 */
	protected boolean doAfter=true;
	/**
	 * 验证提示类型
	 */
	protected int tipType=ActionResult.TIPTYPE_NONE;
	/**
	 * 验证返回信息
	 */
	protected String info="";
	
	public BaseVerify(boolean doAfter, int tipType, String info) {
		super();
		this.doAfter = doAfter;
		this.tipType = tipType;
		this.info = info;
	}

	/**
	 * 验证
	 * @return
	 */
	public ActionResult verify(List<T> list){
		ActionResult vr=new ActionResult(doAfter,tipType,info);
		if(list!=null&&!list.isEmpty()){
			for(T obj:list){
				ActionResult vrTemp=verify(obj);
				if(!vrTemp.isSuccess()){
					return vrTemp;
				}
			}
		}
		return vr;
	}
	
	/**
	 * 验证
	 * @return
	 */
	public ActionResult verify(T obj){
		return new ActionResult(doAfter,tipType,info);
	}
	
	public boolean isDoAfter() {
		return doAfter;
	}
	public void setDoAfter(boolean doAfter) {
		this.doAfter = doAfter;
	}
	public int getTipType() {
		return tipType;
	}
	public void setTipType(int tipType) {
		this.tipType = tipType;
	}
	public String getInfo() {
		return info;
	}
	public void setInfo(String info) {
		this.info = info;
	}
	
}
